import { fileURLToPath, URL } from 'node:url'
import electron from 'vite-plugin-electron/simple';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { dirResolver } from "vite-auto-import-resolvers";
import AutoImport from "unplugin-auto-import/vite";
// https://vite.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    AutoImport({
      // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
      imports: ["vue",'pinia'],
      /*dirResolver()  默认识别 composables 文件下的js文件，无需引入，自动加载。可以指定文件夹，如：['src/utils'] */
      resolvers: [dirResolver({ target: "./src/utils" })],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    vue(),
    vueDevTools(),
    electron({
      main: { entry: 'electron/main.js' },
      preload: { entry: 'electron/preload.js' },
    })
  ], build: {
    terserOptions: {
      // 清除console和debugger
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
    outDir: "vue-dist",
    assetsDir: "static",
    chunkSizeWarningLimit: 1000,

  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
